<template>
  <div class="home-hot" ref="target">
    <HomePanel title="人气推荐" subTitle="人气爆款 不容错过">
      <!-- 面板内容 -->

      <transition name="fade" mode="">
        <ul v-if="goods.length" ref="pannel" class="goods-list">
          <li v-for="items in goods" :key="items.id">
            <router-link :to="`/`">
              <img :src="items.picture" alt="">
              <p class="name">{{ items.title }}</p>
              <p class="desc">{{ items.alt }}</p>
            </router-link>
          </li>
        </ul>

        <!-- 缓冲白屏骨架 -->
        <HomeSkeleton v-else />
      </transition>
    </HomePanel>
  </div>
</template>

<script>
import HomePanel from './home-panel.vue'
import HomeSkeleton from './home-skeleton.vue'
import { useLazyData } from '@/hooks'
import { findHot } from '@/api/home'
// import { ref } from 'vue'
export default {
  name: 'HomeHot',
  components: {
    HomePanel,
    HomeSkeleton
  },
  setup () {
    // const goods = ref([])

    // findHot().then(data => {
    //   goods.value = data.result
    //   console.log(data.result)
    // })

    const { target, result } = useLazyData(findHot)

    return { goods: result, target }
  }
}
</script>

<style lang="less" scoped>
 .home-hot {
  .goods-list {
    display: flex;
    justify-content: space-between;
    height: 426px;
    li {
      width: 306px;
      height: 406px;
      .hoverShadow();
      img {
        width: 306px;
        height: 306px;
      }
      p {
        font-size: 22px;
        padding-top: 12px;
        text-align: center;
      }
      .desc {
        color: #999;
        font-size: 18px;
      }
    }
  }
 }
</style>
